/*******************************************************************************
 * Package: com.hngtrust.iir.elk.controller
 * Type:    ElkController
 * Date:    2021-03-20 10:00
 *
 * Copyright (c) 2020 HUANENG GUICHENG TRUST CORP.,LTD All Rights Reserved.
 *
 * You may not use this file except in compliance with the License.
 *******************************************************************************/
package com.hngtrust.iir.elk.controller;

import com.hngtrust.framework.bind.ResponseInfo;
import com.hngtrust.iir.elk.dto.CompResp;
import com.hngtrust.iir.elk.dto.CompSearchReq;
import com.hngtrust.iir.elk.dto.DeleteElkDataReqVO;
import com.hngtrust.iir.elk.dto.IndustryNewsInfoReq;
import com.hngtrust.iir.elk.dto.IndustryNewsInfoResp;
import com.hngtrust.iir.elk.dto.IndustryPointsInfoReq;
import com.hngtrust.iir.elk.dto.IndustryPointsInfoResp;
import com.hngtrust.iir.elk.dto.IndustryReportReq;
import com.hngtrust.iir.elk.dto.IndustryReportResp;
import com.hngtrust.iir.elk.dto.MaterialReq;
import com.hngtrust.iir.elk.dto.NewsInfoReq;
import com.hngtrust.iir.elk.dto.NewsInfoResp;
import com.hngtrust.iir.elk.dto.NewsInfoTagsReq;
import com.hngtrust.iir.elk.dto.NoticeReq;
import com.hngtrust.iir.elk.dto.NoticeResp;
import com.hngtrust.iir.elk.dto.NoticeTagsReq;
import com.hngtrust.iir.elk.dto.ReportReq;
import com.hngtrust.iir.elk.dto.ReportResp;
import com.hngtrust.iir.elk.dto.ReportTagsReq;
import com.hngtrust.iir.elk.service.ElkService;
import com.hngtrust.iir.material.controller.dto.SearchPrivateMaterialVO;
import com.hngtrust.iir.report.controller.dto.SearchPrivateReportVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.security.PermitAll;
import javax.validation.Valid;
import java.util.List;

/**
 * ELK数据检索操作
 * @author Zhangkangkang
 * @date 2021-03-20 10:00
 */
@Slf4j
@Api(tags = "ELK数据检索操作")
@RestController
@RequestMapping("/elk")
public class ElkController {

    @Autowired
    private ElkService elkService;

    /**
     * 公告检索
     */
    @ApiOperation(value = "公告检索", notes = "公告检索")
    @PostMapping("/search-notice")
    @PermitAll
    public ResponseInfo<List<NoticeResp>> searchNotice(
            @ApiParam(value = "公告检索") @Valid @RequestBody NoticeReq noticeReq) {
        List<NoticeResp> result = elkService.searchNotice(noticeReq);
        return new ResponseInfo<>(result);
    }

    /**
     * 研报检索
     */
    @ApiOperation(value = "研报检索", notes = "研报检索")
    @PostMapping("/search-report")
    @PermitAll
    public ResponseInfo<List<ReportResp>> searchReport(
            @ApiParam(value = "研报检索") @Valid @RequestBody ReportReq reportReq) {
        List<ReportResp> result = elkService.searchReport(reportReq);
        
        return new ResponseInfo<>(result);
    }

    /**
     * 新闻资讯检索
     */
    @ApiOperation(value = "新闻资讯检索", notes = "新闻资讯检索")
    @PostMapping("/search-newsinfo")
    @PermitAll
    public ResponseInfo<List<NewsInfoResp>> searchNewsInfo(
            @ApiParam(value = "新闻资讯检索") @Valid @RequestBody NewsInfoReq newsInfoReq) {
        List<NewsInfoResp> result = elkService.searchNewsInfo(newsInfoReq);
        return new ResponseInfo<>(result);
    }

    /**
     * 行业资讯检索
     */
    @ApiOperation(value = "行业资讯检索", notes = "行业资讯检索")
    @PostMapping("/search-industryNewsinfo")
    @PermitAll
    public ResponseInfo<List<IndustryNewsInfoResp>> searchIndustryNewsInfo(
            @ApiParam(value = "行业资讯检索") @Valid @RequestBody IndustryNewsInfoReq newsInfoReq) {
        List<IndustryNewsInfoResp> result = elkService.searchIndustryNewsInfo(newsInfoReq);
        return new ResponseInfo<>(result);
    }

    /**
     * 专家观点检索
     */
    @ApiOperation(value = "专家观点检索", notes = "专家观点检索")
    @PostMapping("/search-industryPointsinfo")
    @PermitAll
    public ResponseInfo<List<IndustryPointsInfoResp>> searchIndustryPointsInfo(
            @ApiParam(value = "行业资讯检索") @Valid @RequestBody IndustryPointsInfoReq pointsInfoReq) {
        List<IndustryPointsInfoResp> result = elkService.searchIndustryPointsInfo(pointsInfoReq);
        return new ResponseInfo<>(result);
    }


    /**
     * 行业研报检索
     */
    @ApiOperation(value = "行业研报检索", notes = "行业研报检索")
    @PostMapping("/search-industryReportInfo")
    @PermitAll
    public ResponseInfo<List<IndustryReportResp>> searchIndustryReportInfo(
            @ApiParam(value = "行业研报检索") @Valid @RequestBody IndustryReportReq reportReq) {
        List<IndustryReportResp> result = elkService.searchIndustryReportInfo(reportReq);

        return new ResponseInfo<>(result);
    }

    @ApiOperation(value = "新闻资讯打标签处理", notes = "新闻资讯打标签处理")
    @PostMapping("/update-newsinfo-tags")
    @PermitAll
    public ResponseInfo<String> updateNewsInfoTags(
            @ApiParam(value = "新闻资讯打标签处理") @Valid @RequestBody NewsInfoTagsReq newsInfoTagsReq){
        this.elkService.updateNewsInfoTags(newsInfoTagsReq.getId(),newsInfoTagsReq.getTags());
        return new ResponseInfo<>();
    }

    @ApiOperation(value = "公告资讯打标签处理", notes = "公告资讯打标签处理")
    @PostMapping("/update-notice-tags")
    @PermitAll
    public ResponseInfo<String> updateNoticeTags(
            @ApiParam(value = "公告资讯打标签处理") @Valid @RequestBody NoticeTagsReq noticeTagsReq){
        this.elkService.updateNoticeTags(noticeTagsReq.getId(),noticeTagsReq.getTags());
        return new ResponseInfo<>();
    }

    @ApiOperation(value = "研报打标签处理", notes = "研报打标签处理")
    @PostMapping("/search-report-tags")
    @PermitAll
    public ResponseInfo<String> updateReportTags(
            @ApiParam(value = "研报打标签处理") @Valid @RequestBody ReportTagsReq reportTagsReq){
        this.elkService.updateReportTags(reportTagsReq.getId(),reportTagsReq.getTags());
        return new ResponseInfo<>();
    }
    
    @ApiOperation(value = "根据公司名检索",notes = "根据公司名检索")
    @PostMapping("/search-comp-name")
    public ResponseInfo<List<CompResp>> searchCompName(@ApiParam(value = "研报打标签处理") @Valid @RequestBody CompSearchReq req){
        List<CompResp> compResps = elkService.searchCompInfo(req);
        return new ResponseInfo(compResps);
    }
 
    
    @ApiOperation("删除elk重复数据")
    @PostMapping("/delete-elk-data")
    public ResponseInfo<String> deleteElkData(@ApiParam("检索参数") @Valid @RequestBody DeleteElkDataReqVO vo){
        elkService.deleteElkData(vo);
        return new ResponseInfo<>();
    }
    
    @ApiOperation("检索内部研报")
    @PostMapping("/search-private-report")
    public ResponseInfo<List<SearchPrivateReportVO>> searchPrivateReport(@ApiParam("检索参数") @Valid @RequestBody ReportReq reportReq){
        List<SearchPrivateReportVO> searchPrivateReportVOS = elkService.searchPrivateReport(reportReq);
        return new ResponseInfo(searchPrivateReportVOS);
    }

    @ApiOperation("检索内部资料")
    @PostMapping("/search-private-material")
    public ResponseInfo<List<SearchPrivateMaterialVO>> searchPrivateMaterial(@ApiParam("检索参数") @Valid @RequestBody MaterialReq materialReq){
        List<SearchPrivateMaterialVO> searchPrivateMaterialVOS = elkService.searchPrivateMaterial(materialReq);
        return new ResponseInfo(searchPrivateMaterialVOS);
    }
    
}
